const query = require('../index');

module.exports = {
  add(data) {
    const sql = `INSERT INTO activity VALUE(NULL, ?, ?, ?,?,?,?,?,?,DEFAULT,DEFAULT,?,DEFAULT,?);
`;
    return query(sql, data);
  },
  joinActivity() {

  },
  list(data) {
    const sql = `SELECT * FROM activity WHERE state=1 ORDER BY activity_id DESC LIMIT ?,?`;
    return query(sql, data);
  },
  detail(data) {
    const sql = `SELECT * FROM activity WHERE activity_id=?`;
    return query(sql, data)
  },
  findUser(data) {
    const sql = `SELECT * FROM app_users WHERE openid=?`;
    return query(sql, data)
  },
  addCount(data) {
    const sql = `UPDATE activity SET current_count=? WHERE activity_id=?`;
    return query(sql, data)
  },
  addUser(data) {
    const sql = `INSERT INTO activity_detail VALUE(NULL, ?, ?)`;
    return query(sql, data)
  },
  activityJoinNotify(data) {
    const sql = `INSERT INTO activity_notify VALUE(NULL, '您的活动有新参与者',2,?,5,?,1,?,DEFAULT,DEFAULT)`;
    return query(sql, data)
  },
  activityNotify(data) {
    const sql = `SELECT * FROM activity_notify WHERE user_id=? AND is_read=0`;
    return query(sql, data)
  }
}